package com.yhy.wxzn.wcs.device.rgv.enums;

import com.alibaba.fastjson.serializer.JSONSerializable;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.fasterxml.jackson.annotation.JsonValue;

import java.io.IOException;
import java.lang.reflect.Type;


public enum RgvStatus implements JSONSerializable {
    /**
     * 行驶中（1）
     */
    RUNNING(1, "行驶中"),
    /**
     * 指令执行中（2）
     */
    MOVING(2, "动作中"),
    /**
     * 就绪(3)(上线且空闲)
     */
    READY(3, "就绪"),
    /**
     * 暂停
     */
    PAUSE(4, "暂停"),
    /**
     * 充电中
     */
    CHARGING(5, "充电中"),
    /**
     * 故障(6)
     */
    ERROR(6, "故障"),
    /**
     * 故障(6)
     */
    SHUT_UP(7, "休眠"),
    /**
     * 离线（255）
     */
    OFF_LINE(255, "离线"),

    /**
     * 节点待命(11)
     */
    NODE_STANDBY(11, "待命中"),

    /**
     * 节点待命(30)
     */
    SEND_MAP(12, "发送地图"),

    /**
     * 节点待命(30)
     */
    EXTRACT_LOG(0xFF02, "提取日志"),
    /**
     * 未知状态
     */
    UNKNOWN(-1, "未知"),
    ;
    private int rgvStatus;
    private String description;

    RgvStatus(int rgvStatus, String description) {
        this.rgvStatus = rgvStatus;
        this.description = description;
    }


    public int getRgvStatus() {
        return rgvStatus;
    }

    @JsonValue
    public String getDescription() {
        return description;
    }

    @Override
    public String toString() {
        return description;
    }

    @Override
    public void write(JSONSerializer jsonSerializer, Object o, Type type, int i) throws IOException {
        jsonSerializer.write(this.getDescription());
    }

}
